package com.zzptc.easyshop.servlet;

import com.zzptc.easyshop.vo.Users;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "UpdateUserServlet")
public class UpdateUserServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //处理乱码
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=UTF-8");
        //接收ID
        String id=request.getParameter("id");
        String type=request.getParameter("type");
        Users users=null;

        HttpSession session=request.getSession();

        List<Users> list=(List)session.getAttribute("allusers");
        for (Users s:list){
            if (s.getEu_user_id().equals(id)){
                users=s;
                break;
            }
        }
        session.setAttribute("userinfo",users);
        request.getRequestDispatcher("manager/user-modify.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            doPost(request,response);

    }
}
